package com.itheima.group;

import org.apache.commons.io.output.NullWriter;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class GroupMapperTask extends Mapper<LongWritable, Text,OrderBean, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();
        if(line!=null & !"".equals(line)){
            OrderBean orderBean = new OrderBean();
            String[] split = line.split("\t");
            orderBean.setOrderId(split[0]);
            orderBean.setPdtId(split[1]);
            orderBean.setPrice(Double.parseDouble(split[2]));

            context.write(orderBean,NullWritable.get());
        }
    }
}
